/**
 * @Description：
 * @author： YouYu 游宇
 * @createTime: 2018-12-05 5:04 PM
 **/

package com.scb.dev.mms.controller;

import com.scb.dev.mms.common.ResponseResult;
import com.scb.dev.mms.request.RoleVORequest;
import com.scb.dev.mms.service.IRoleService;
import com.scb.dev.mms.service.impl.RoleServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @className: RoleController
 * @Description:
 * @author: YouYu 游宇
 * @createTime: 2018-12-05 5:04 PM
 **/
@Slf4j
@RestController
@RequestMapping("/sm/role")
@Api(value = "RoleController", description = "RoleController API")
public class RoleController {
    @Autowired
    private IRoleService roleService;

    @ApiOperation(value="selectAllRole", notes="you can use this API to get all the role info")
    @RequestMapping(value="/selectAllRole",method = RequestMethod.GET)
    public ResponseResult selectAllRole(){
        ResponseResult responseResult=new ResponseResult();
        responseResult=roleService.queryAllRole();
        return responseResult;
    }

    @ApiOperation(value="selectAllRoleName", notes="you can use this API to get all the role names")
    @RequestMapping(value="/selectAllRoleName",method = RequestMethod.GET)
    public ResponseResult selectAllRoleName(){
        ResponseResult responseResult=new ResponseResult();
        responseResult=roleService.queryAllRoleName();
        return responseResult;
    }


    @ApiOperation(value="roleName", notes="you can use this API to get the roleName  according to roleId")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="path",name = "roleId",value = "roleId",required = true ,dataType = "String"),
    })    @RequestMapping(value="/roleName/{roleId}",method = RequestMethod.GET)
    public ResponseResult selectRoleNameByRoleId(@PathVariable("roleId")String roleId){
        ResponseResult responseResult=new ResponseResult();
        responseResult=roleService.queryRoleNameByRoleId(roleId);
        return responseResult;
    }


    @ApiOperation(value="selectMenusByRoleId", notes="you can use this API to get menus according to roleId")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="path",name = "roleId",value = "roleId",required = true ,dataType = "String"),
    })
    @RequestMapping(value="/selectMenus/{roleId}",method = RequestMethod.GET)
    public ResponseResult selectMenusByRoleId(@PathVariable("roleId") String roleId){
        log.info("Role Controller -> queryMenusByRoleId  get menuId by roleId");
        ResponseResult responseResult = roleService.queryMenusByRoleId(roleId);
        return responseResult;
    }

    @ApiOperation(value="addRole", notes="you can use this API to add a new role")
    @RequestMapping(value="/addRole",method=RequestMethod.POST)
    public ResponseResult addRole(@RequestBody RoleVORequest RoleVORequest){
        ResponseResult responseResult=roleService.addRole(RoleVORequest);
        return responseResult;
    }

    @ApiOperation(value="deleteRole", notes="you can use this API to delete role by roleId")
    @RequestMapping(value="/delete/{roleId}",method=RequestMethod.DELETE)
    public ResponseResult addRole(@PathVariable("roleId")String roleId){
        ResponseResult responseResult=roleService.deleteRole(roleId);
        return responseResult;
    }

    @ApiOperation(value="updateRole", notes="you can use this API to update a role")
    @RequestMapping(value="/updateRole",method=RequestMethod.PUT)
    public ResponseResult updateRole(@RequestBody RoleVORequest RoleVORequest){
        ResponseResult responseResult=roleService.updateRole(RoleVORequest);
        return responseResult;
    }


}
